﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Ivan.Dm.ChromeRemoteDebugger.Protocol {
    public struct CommandJsonFieldNames {
        public const string Command = "command";
        public const string Result = "result";
        public const string Data = "data";
    }

    public struct ToolNames {
        public const string DevToolsService = "DevToolsService";
        public const string V8 = "V8Debugger";
    }

    public struct DevToolsServiceCommandNames {
        public const string Ping = "ping";
        public const string Version = "version";
        public const string ListTabs = "list_tabs";
    }

    public struct V8CommandNames {
        public const string Attach = "attach";
        public const string Detach = "detach";
        public const string DebuggerCommand = "debugger_command";
        public const string EvaluateJavaScript = "evaluate_javascript";
        public const string Navigated = "navigated";
        public const string Closed = "closed";
    }

    public enum DevToolsServiceCommandResult : int {
        Ok = 0,
        UnknownCommand
    }

    public enum V8CommandResult : int {
        Ok = 0,
        IllegalTabState,
        UnknownTab,
        DebuggerError,
        UnknownCommand
    }

    [DataContract]
    public class Command {
        [DataMember(Name = CommandJsonFieldNames.Command)]
        public string Name { get; set; }
        public string Tool { get; set; }
        public string Destination { get; set; }
    }

    [DataContract]
    public abstract class DevToolsServiceCommandResponse : Command {
        [DataMember(Name = CommandJsonFieldNames.Result)]
        public DevToolsServiceCommandResult Result { get; set; }
    }

    [DataContract]
    public abstract class V8CommandResponse : Command {
        [DataMember(Name = CommandJsonFieldNames.Result)]
        public V8CommandResult Result { get; set; }
    }
}
